home *** CD-ROM | disk | FTP | other *** search
/ PC Open 100 / PC Open 100 CD 2.bin / CD2 / PDF / Corsi / webdeveloper / lezione_4 / elencofoto4.asp < prev    next >
Encoding:
Text File  |  2004-10-01  |  2.5 KB  |  123 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2.  
  3. <html>
  4. <head>
  5.     <title>Le foto di Mario Rossi</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <h1>Le mie foto preferite</h1>
  11.  
  12. Hai selezionato le foto che parlano di <%=request.QueryString("rfoto")%><br>
  13. <%
  14.  
  15. Const adOpenStatic = 3
  16. Const adLockReadOnly = 1
  17. Const adOpenForwardOnly = 0
  18.  
  19. Dim contatore
  20. Dim sql1,sql2
  21. Dim conn, rs
  22. Dim pagNum
  23. Dim pagSize
  24. Dim i,j
  25.  
  26. pagSize = 2
  27.  
  28. Set conn = Server.CreateObject("ADODB.Connection")
  29. conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/foto2.mdb")
  30.  
  31. sql1 = "SELECT count(nome) AS contatore FROM Foto WHERE Titolo like '%" & request.QueryString("rfoto") & "%'"
  32. sql2 = "SELECT * FROM Foto WHERE Titolo like '%" & request.QueryString("rfoto") & "%' ORDER BY Data DESC "
  33.  
  34. Set rs = Server.CreateObject("ADODB.RecordSet")
  35. rs.Open sql1, conn, adOpenForwardOnly, adLockReadOnly
  36.  
  37. contatore = rs("contatore")
  38.  
  39. rs.Close()
  40.  
  41.  
  42. 'Estrae il numero di pagina
  43. pagNum = cint(request.QueryString("pag"))
  44. If pagNum = 0 Then pagNum = 1
  45.  
  46. 'Imposta la dimensione della pagina (il numero massimo di elementi da far comparire per ogni pagina)
  47. rs.PageSize = pagSize
  48.  
  49. rs.Open sql2, conn, adOpenStatic, adLockReadOnly
  50.  
  51. %>
  52.  
  53. Sono presenti <%=contatore%> foto che soddisfano i criteri di ricerca<br><br>
  54.  
  55. <%
  56.  
  57.  
  58. rs.AbsolutePage = pagNum
  59.  
  60. for i = 1 to pagSize
  61.  
  62.     if not rs.EOF Then
  63.  
  64.         if i mod 2 = 0 then
  65.             strColor="#3333CC"
  66.         else
  67.             strColor="#FF0033"
  68.         end if
  69.  
  70. %>
  71.  
  72. <li><a style="color:<%=strColor%>" href="../../../../../PDF/Corsi/webdeveloper/lezione_4/dettagliofoto.asp?nome=<%=rs("Nome")%>"><%=rs("Titolo")%>, scattata a <%=rs("Luogo")%></a></li>
  73.  
  74. <%
  75.         rs.movenext
  76.  
  77.     Else
  78.  
  79.         Exit For
  80.  
  81.     End If
  82.  
  83.  
  84. next
  85.  
  86. %>
  87.  
  88. <br><hr><br>
  89.  
  90. <div align="left">
  91.  
  92. <%    If pagNum > 1 Then %>
  93.     <a href="../../../../../PDF/Corsi/webdeveloper/lezione_4/<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum -1%><%=strTipo%>">«</a>
  94. <%    End If %>
  95.  
  96. <% for j = 1 to rs.PageCount %>
  97.     <% if j = pagNum then %>
  98.         <strong><%=j%></strong>
  99.     <% else %>
  100.         <a href="../../../../../PDF/Corsi/webdeveloper/lezione_4/<%=request.ServerVariables("PATH_INFO")%>?pag=<%=j%><%=strTipo%>"><%=j%></a>
  101.     <% end if %>
  102. <% next %>
  103.  
  104. <%    If pagNum < rs.PageCount Then %>
  105.     <a href="../../../../../PDF/Corsi/webdeveloper/lezione_4/<%=request.ServerVariables("PATH_INFO")%>?pag=<%=pagNum+1%>">»</a>
  106. <%    End If %>
  107.  
  108. </div>
  109.  
  110. <%
  111. rs.close
  112. set rs = nothing
  113. conn.close
  114. set conn = nothing
  115.  
  116. %>
  117.  
  118. </ul>
  119.  
  120. </body>
  121. </html>
  122.  
  123.